void loadBinary(char* file)
{
	
	char x;
    	int xpos = 0;
	FILE* bin = fopen(file,"r");
	fseek(bin, 0L, SEEK_END); 
	int fileSize = ftell(bin);
	fseek(bin, 0L, SEEK_SET);
	while  ( xpos < fileSize )
	{
		x = fgetc( bin );
		RAM[xpos] = x;
		xpos++;
	}
	heapPointer = fileSize;
	fclose(bin);
}

void loadGEX(char* file)
{
	char* GEX = (char*)openGEX(file);
	GEXHdr* hdr = (GEXHdr*)GEX;
	int textSize = 0;
	theProgram = GEX;
	if(strncmp("GEX4 SC",hdr->magic,7) == 0)
	{
		for(int i = 0; i < hdr->sectionCount;i++)
		{
			GEXShdr* section = (GEXShdr*)(GEX + (hdr->sectionTable + (i * sizeof(GEXShdr))));
			if(strncmp(section->name,".text",5) == 0)
			{
				textSize = section->length;
				memcpy(RAM,GEX + section->ptr,section->length);
				heapPointer += section->length;
			}
			else if (strncmp(section->name,".data",5) == 0)
			{
				memcpy(RAM + textSize ,GEX + section->ptr,section->length );
				heapPointer += section->length;
			}
		}
		dumpRam();
		
	}
	else
	{
		printf("Error: Invalid GEX Header! Aborting!\n");
		return 0; 
	}
}
